<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>
    <style>
        .mdui-table-fluid {
            width: 1200px;
        }

        .mdui-table {
            border: 1px solid #d6d6d6;
        }

        .mdui-btn {
            margin-right: 100px;
        }

        a {
            text-decoration: none;
        }

        .mdui-table-fluid {
            width: 800px;
        }

        .mdui-table td img {
            height: 100px;
            width: 140px;
        }
    </style>

</head>
<div id="app">

    <h3>报修单编号{{repair.id}}</h3>
    <button class="mdui-btn mdui-color-green-800 mdui-ripple"><a href="list.html"
                                                                 class=" mdui-color-green-800">返回上一级</a>
    </button>
    <button v-if="flag" class="mdui-btn mdui-color-green-800 mdui-ripple"><a :href="'uplode.html?id='+repair.id"
                                                                             class=" mdui-color-green-800">修改</a>
    </button>

    <button v-if="flag1" class="mdui-btn mdui-color-green-800 mdui-ripple" @click="addReminder">催单</button>

    <button v-if="flag2" class="mdui-btn mdui-color-green-800 mdui-ripple" @click="check">验收</button>

    <div class="mdui-table-fluid">

        <table class="mdui-table">
            <thead>
            <tr>
                <th>特征</th>
                <th>描述</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>地点</td>
                <td>{{repair.place}}</td>
            </tr>
            <tr>
                <td>时间</td>
                <td>{{repair.submitTime}}</td>
            </tr>
            <tr>
                <td>状态</td>
                <td>{{repair.status |fmtGenter}}</td>
            </tr>
            <tr>
                <td>详情</td>
                <td>{{repair.detail}}</td>
            </tr>
            <tr>
                <td>花费</td>
                <td>{{repair.cost}}</td>
            </tr>
            <tr>
                <td>备注</td>
                <td>{{repair.remark}}</td>
            </tr>

            <tr>
                <td>图片</td>
                <td class="img-hight"><img :src="'/repair/downlode/' + repair.id">
                </td>

            </tr>

            </tbody>
        </table>
    </div>
</div>


<script>
    let params = new URLSearchParams(location.search);//location.searc url中参数的部分包括问号
    let repairid = params.get("id")
    new Vue({
        el: '#app',
        data:
            {
                repair: {
                    id: '',
                    status: "",
                    detail: "",
                    place: "",
                    picMD5: "",
                    submitTime: ""
                },
                flag: true,//修改
                flag1: true,//催单
                flag2: true//验收
            },
        created() {
            let _this = this
            axios.get("/repair/findById?id=" + repairid)
                .then(function (res) {
                    _this.repair = res.data;
                    console.log(res.data)
                    if (res.data.status == 5) {
                        _this.flag = false
                        _this.flag1 = false
                    }
                    if (res.data.status == 6) {
                        _this.flag = false
                        _this.flag1 = false
                        _this.flag2 = false
                    }
                    if (res.data.status == 1) {
                        _this.flag2 = false
                    }
                    if (res.data.status == 3) {
                        _this.flag = false
                        _this.flag1 = false
                        _this.flag2 = false
                    }
                    if (res.data.status == 3) {
                        _this.flag = false
                        _this.flag1 = false

                    }
                })
        },
        filters: {
            fmtGenter(val) {
                if (val == 1) {
                    return "未安排维修维修"
                } else if (val == 2) {
                    return "已安排检修"
                } else if (val == 3) {
                    return "待同意取消"
                } else if (val == 4) {
                    return "已同意取消"
                } else if (val == 5) {
                    return "待验收"
                } else if (val == 6) {
                    return "已验收"
                }
            }
        },
        methods: {
            check() {
                console.log(this.name)
                let _this = this
                axios.get("/repair/check", {
                    params: {
                        id: repairid
                    }
                })
                    .then(function (res) {
                        if (res.data) {
                            mdui.alert("验收成功")
                        }
                    })
            },
            addReminder() {
                console.log(123121343)
                let _this = this;
                axios.post("/urgent/addUrgent?id=" + repairid)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("催单成功");
                        } else {
                            mdui.alert("已经催单");
                        }
                    })
            },
        }
    })

</script>
</body>
</html>